<?php
class FileConfig extends CronjobConfig
{
	public $namespace;
	public $poolPath = null;
	protected $poolFile = null;
	protected $_prototype;
		
	public function __construct(){
		$this->init();
	}
	
	public function init(){
		$this->poolPath = Yii::getPathOfAlias('application.commands.pool.run');
		$this->buildPool();
	}
		
	public function buildPool(){
		if (!file_exists($this->poolPath)) {
			mkdir($this->poolPath,0777,true);
		}
	}
	
	public function setNamespace($namesapce){
		$this->namespace = $namesapce;
		$this->poolFile = $this->poolPath.'/'.$this->namespace.'.config';
	}
	
	public function set($config){
		file_put_contents($this->poolFile,json_encode($config));
	}
	
	public function get(){
		$config = file_get_contents($this->poolFile);
		$config = json_decode($config,true);
		return $config;
	}
	
	public function clear(){
		unlink($this->poolFile);
	}
	
}

